// Texas A&M University          //
// cpsc321 Computer Architecture //
// $Id: lshift2.v,v 1.2 2002/04/08 23:39:07 miket Exp miket $ //

module Shifter(ShiftCtr, in, out, shamt);

   input [31:0] in;
	 input [1:0] ShiftCtr;
	 input [4:0] shamt;
   output [31:0] out;
	 reg [31:0] out;

	 always @(ShiftCtr or in or shamt)
				if(ShiftCtr == 0) 
					  out <= in;
	      else if(ShiftCtr == 1) 
					begin
					  out <= (in << shamt);
				  end
				else if(ShiftCtr == 2)
					begin
            out <= (in >> shamt);
				  end
			  else if(ShiftCtr == 3)		
					begin
//					  out[31-shamt:0] <= in[31:shamt];
//				  	out[31:31-shamt] <= {shamt{in[31]}};
					end

endmodule

/*
 module TestShift;
 wire [31:0] out;
 reg [31:0] in;
 reg [4:0] shamt;
 reg [1:0] ShiftCtr;
 
 Shifter shift1(ShiftCtr,in,out,shamt);
 
initial begin	
 $monitor($time, "Ctr=%d in=%d out=%d shamt=%d",ShiftCtr,in,out,shamt);
 in = 32;
 shamt = 2;
 ShiftCtr = 0;
 #1 ShiftCtr = 1;
 #1 shamt = 6;
#1 shamt = 15;
 #1 ShiftCtr = 1;
 #1 ShiftCtr = 2;
 #1 $finish;
end
endmodule
*/
